<template>
  <a-card class="info" title="职务级别">
    <template slot="extra">
      <template v-if="model.auditStatus==0">
        <a-button
          class="ruleButton"
          :ghost="true"
          type="primary"
          icon="edit"
          @click="handleEdit(model)"
          :disabled="isDisabledAuth('erpOrgPositionLevel:edit')"
        />
        <a-divider type="vertical"/>
        <a-popconfirm title="确定提交吗?" @confirm="() => handleSubmit(model.id)">
          <a-button type="primary" size="small" :disabled="isDisabledAuth('erpOrgPositionLevel:submit')">提交</a-button>
        </a-popconfirm>
      </template>
      <template v-if="model.auditStatus==1">
        <a-button type="primary" size="small" @click="handleAudit(model.id)"
                  :disabled="isDisabledAuth('erpOrgPositionLevel:audit')">审核
        </a-button>
      </template>
      <template v-if="model.auditStatus==2">
        <a-popconfirm title="确定反审吗?" @confirm="() => handleCounterTrial(model.id)">
          <a-button type="primary" size="small" :disabled="isDisabledAuth('erpOrgPositionLevel:counterTrial')">反审
          </a-button>
        </a-popconfirm>
      </template>
    </template>
    <a-row type="flex" justify="center">
      <a-col :span="24">
        <erp-org-position-level-form ref="realForm" :disabled="true" normal></erp-org-position-level-form>
      </a-col>
    </a-row>
    <erp-org-position-level-modal ref="modalForm" @ok="modalFormOk"></erp-org-position-level-modal>
    <audit-modal ref="auditModal" @ok="modalFormOk"></audit-modal>
  </a-card>
</template>

<script>

import { getAction } from '@/api/manage'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import ErpOrgPositionLevelForm from './modules/ErpOrgPositionLevelForm'
import ErpOrgPositionLevelModal from './modules/ErpOrgPositionLevelModal'
import { DisabledAuthFilterMixin } from '@/mixins/DisabledAuthFilterMixin'

export default {
  name: 'ErpOrgPositionLevelDetail',
  mixins: [JeecgListMixin, DisabledAuthFilterMixin],
  components: {
    ErpOrgPositionLevelForm,
    ErpOrgPositionLevelModal,
  },
  data() {
    return {
      model: {},
      id: '',
      url: {
        queryById: '/api/erp/org/positionlevel/erpOrgPositionLevel/queryById',
        delete: '/api/erp/org/positionlevel/erpOrgPositionLevel/delete',
        submit: '/api/erp/org/positionlevel/erpOrgPositionLevel/submit',
        revoke: '/api/erp/org/positionlevel/erpOrgPositionLevel/revoke',
        counterTrial: '/api/erp/org/positionlevel/erpOrgPositionLevel/counterTrial',
        audit: '/api/erp/org/positionlevel/erpOrgPositionLevel/audit',
        overrule: '/api/erp/org/positionlevel/erpOrgPositionLevel/overrule',
      },
      confirmLoading: false,
      iconStyle: { 'font-size': '20px' },
    }
  },
  created() {
  },
  watch: {
    $route(to, from) {
      this.loadData();
    },
  },
  mounted() {
  },
  methods: {
    loadData() {
      const id = this.$route.params.id;
      getAction(this.url.queryById, { id }).then((res) => {
        if (res.success) {
          const model = res.result
          this.$refs.realForm.edit(model);
          this.model = model;
        }
      })
    },
  }
}
</script>
<style lang="less" scoped>
@import '~@assets/less/common.less';

.info {
  /deep/ .ant-card-head-title {
    flex: none;
    margin-right: 20px;
  }

  /deep/ .ant-card-extra {
    flex: 1;
    float: left;
  }
}
</style>
